package main

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/logs"
	"i-hea.com/ttsc/controllers"
	"i-hea.com/ttsc/kdxf"
	_ "i-hea.com/ttsc/routers"
	"i-hea.com/ttsc/ttsclient"
	"i-hea.com/utils/models"
)

func modelsInit() {

	user := beego.AppConfig.String("myuser")
	pwd := beego.AppConfig.String("mypwd")
	serv := beego.AppConfig.String("mysql")

	err := models.Init(user, pwd, serv)
	if err != nil {
		panic(err)
	} else {
		logs.Debug("model init success")
	}
}

func main() {

	beego.SetLogger("file", `{"filename":"./logs/ttsc.log"}`)

	//设置日志层级
	logs.SetLogFuncCallDepth(3)

	controllers.SignServer = beego.AppConfig.String("signServer")

	//fsclient.StartNewClient(fsServer, 2)
	ttsClient := beego.AppConfig.DefaultString("client", "qcloud")
	if ttsClient == "qcloud" {
		ttsclient.Init()
	}

	modelsInit()

	models.RegIpccAppManager()
	kdxf.Init()

	beego.Run()
}
